package com.appkubes.fintech.admin.application.repair;


import com.appkubes.fintech.admin.application.repair.request.RepairOrderItemRequest;
import com.appkubes.fintech.admin.application.repair.response.RepairOrderItemResponse;
import com.appkubes.fintech.admin.application.repair.service.RepairOrderItemService;
import com.appkubes.fintech.common.response.Response;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/*
 *
 * @author xqc
 * @date 	2020/02/05 10:50:56
 */
@RestController
@RequestMapping("repair/repairOrderItem")
@Api(tags = "订单明细", value = "RepairOrderItemController")
@Slf4j
public class RepairOrderItemController {

    @Autowired
    private RepairOrderItemService repairOrderItemService;


    @ApiOperation(tags = "分页订单明细", value = "queryPage")
    @PostMapping(value = "queryPage")
    public Response<PageInfo<RepairOrderItemResponse>> queryPage(@RequestBody RepairOrderItemRequest repairOrderItemRequest) {

        PageInfo<RepairOrderItemResponse> pageInfo = repairOrderItemService.queryPage(repairOrderItemRequest);
        return Response.success(pageInfo);
    }

    @ApiOperation(tags = "新增订单明细", value = "save")
    @PostMapping(value = "save")
    public Response save(@RequestBody RepairOrderItemRequest repairOrderItemRequest) {

        return repairOrderItemService.save(repairOrderItemRequest);

    }

    @ApiOperation(tags = "更新订单明细", value = "update")
    @PostMapping(value = "update")
    public Response update(@RequestBody RepairOrderItemRequest repairOrderItemRequest) {

        return repairOrderItemService.update(repairOrderItemRequest);
    }

    @ApiOperation(tags = "删除订单明细", value = "delete")
    @PostMapping(value = "delete")
    public Response delete(String id) {
        return repairOrderItemService.deleteRepairOrderItem(id);
    }

    @ApiOperation(tags = "获取订单明细", value = "getById")
    @PostMapping(value = "getById")
    public Response<RepairOrderItemResponse> getById(String id) {
        return repairOrderItemService.getById(id);

    }

}
